﻿<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="Sobiens.WPF.Controls.Styles.DataGridGeneric"
	xmlns:WpfToolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
    xmlns:Primitives="clr-namespace:Microsoft.Windows.Controls.Primitives;assembly=WPFToolkit"
	xmlns:ExtendedGridControl="clr-namespace:Sobiens.WPF.Controls.ExtendedGridControl"
	xmlns:UserControls="clr-namespace:Sobiens.WPF.Controls.UserControls">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Brushes.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <!-- Value converters -->
    <BooleanToVisibilityConverter x:Key="bool2VisibilityConverter" />
    <ContextMenu x:Key="DataGridHeaderColumnChooser" StaysOpen="True" HorizontalContentAlignment="Stretch" Width="Auto" HorizontalAlignment="Stretch">
        <MenuItem StaysOpenOnClick="True" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch">
            <MenuItem.Header>
                <UserControls:ColumnChooserControl></UserControls:ColumnChooserControl>
            </MenuItem.Header>
        </MenuItem>
    </ContextMenu>

    <!-- DataGridColumnHeader Right Gripper Style -->
    <Style x:Key="ColumnHeaderRightGripperStyle" TargetType="{x:Type Thumb}">
        <Setter Property="Width" Value="8"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Cursor" Value="SizeWE"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Padding="{TemplateBinding Padding}"
							Background="{TemplateBinding Background}">
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!-- DataGridColumnHeader Left Gripper Style -->
    <Style x:Key="ColumnHeaderLeftGripperStyle" 
		   BasedOn="{StaticResource ColumnHeaderRightGripperStyle}" 
		   TargetType="{x:Type Thumb}">
        <Setter Property="Width" Value="8"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Cursor" Value="SizeWE"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Name="Border"
							Padding="{TemplateBinding Padding}" 
							Background="{TemplateBinding Background}">
                        <Canvas>
                            <Line RenderOptions.EdgeMode="Aliased" Stroke="#88B0E4"
								  X1="7" Y1="{Binding ElementName=Border, Path=ActualHeight}"
								  X2="7" Y2="0"/>
                        </Canvas>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <!-- DataGridColumnHeader Style -->
    <Style x:Key="ColumnHeaderStyle" TargetType="{x:Type WpfToolkit:DataGridColumnHeader}">
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Background" Value="{StaticResource HeaderBackgroundBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource HeaderBorderBrush}" />
        <Setter Property="BorderThickness" Value="0,1,0,1" />
        <Setter Property="ContextMenu" Value="{StaticResource DataGridHeaderColumnChooser}"/>
        <Setter Property="Height" Value="30"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type WpfToolkit:DataGridColumnHeader}">
                    <Grid>
                        <WpfToolkit:DataGridHeaderBorder
							x:Name="headerBorder"
                            HorizontalAlignment="Stretch"
							SortDirection="{TemplateBinding SortDirection}"
							IsHovered="{TemplateBinding IsMouseOver}"
							IsPressed="{TemplateBinding IsPressed}"
							IsClickable="{TemplateBinding CanUserSort}"
							Background="{TemplateBinding Background}"
							BorderBrush="{TemplateBinding BorderBrush}"
							BorderThickness="{TemplateBinding BorderThickness}"
							Padding ="{TemplateBinding Padding}"
							SeparatorVisibility="{TemplateBinding SeparatorVisibility}"
							SeparatorBrush="{TemplateBinding SeparatorBrush}">
                            <Border BorderBrush="{StaticResource HeaderInnerBorderBrush}" 
									BorderThickness="0,1,0,0">
                                <DockPanel LastChildFill="True">
                                    <Popup x:Name="popupDrag" StaysOpen="True" IsHitTestVisible="True" Placement="RelativePoint"  PlacementTarget="{Binding}" AllowsTransparency="False" IsOpen="False" MinWidth="150" MaxWidth="200" Tag="False">
                                        <StackPanel LostFocus="PopLostFocus" Focusable="True">
                                            <Button FontFamily="{TemplateBinding FontFamily}" FontSize="9" MinHeight="24" IsEnabled="True" Foreground="Black"  LostFocus="PopLostFocus" Click="SortByAscButton_Click" x:Name="SortByAscButton">
                                                <StackPanel Orientation="Horizontal">
                                                    <Image Source="/Sobiens.WPF.Controls;component/Images/SORTAZ.GIF"/>
                                                    <Label Padding="0">Ascending</Label>
                                                </StackPanel>
                                            </Button>
                                            <Button FontFamily="{TemplateBinding FontFamily}" FontSize="9" MinHeight="24" IsEnabled="True" Foreground="Black"  LostFocus="PopLostFocus" Click="SortByDescButton_Click" x:Name="SortByDescButton">
                                                <StackPanel Orientation="Horizontal">
                                                    <Image Source="/Sobiens.WPF.Controls;component/Images/SORTZA.GIF"/>
                                                    <Label Padding="0">Descending</Label>
                                                </StackPanel>
                                            </Button>
                                            <Button FontFamily="{TemplateBinding FontFamily}" FontSize="9" MinHeight="24" IsEnabled="False" Foreground="Black"  LostFocus="PopLostFocus" Click="ClearClicked" x:Name="btnClear">(Clear Filter)</Button>
                                            <ListBox x:Name="autoFilterList" FontFamily="{TemplateBinding FontFamily}" MaxHeight="350" VirtualizingStackPanel.IsVirtualizing="True" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto">
                                                <ListBox.ItemTemplate>
                                                    <DataTemplate>
                                                        <CheckBox x:Name="chkBox" Margin="0" FontSize="9"  Content="{Binding Name}" IsChecked="{Binding IsChecked}" Checked="Checked" Unchecked="UnChecked" Tag="{Binding IsSelectAll}"/>
                                                        <DataTemplate.Triggers>
                                                            <Trigger SourceName="chkBox" Property="Tag" Value="(Select All)">
                                                                <Setter TargetName="chkBox" Property="FontWeight" Value="Bold" />
                                                            </Trigger>
                                                        </DataTemplate.Triggers>
                                                    </DataTemplate>
                                                </ListBox.ItemTemplate>
                                            </ListBox>
                                        </StackPanel>
                                    </Popup>
                                    <ContentControl x:Name="autofilter" Focusable="True" Margin="0,0,2,0" MouseDown="AutoFilterMouseDown" MouseRightButtonDown="AutoFilterRightMouseDown"  Visibility="Collapsed" DockPanel.Dock="Right" Style="{x:Null}" VerticalAlignment="Center" BorderBrush="Transparent" BorderThickness="0" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Loaded="AutoFilterGlphLoaded">
                                        <ContentControl.Background>
                                            <LinearGradientBrush StartPoint="0.5,0.0" EndPoint="0.5,1.0">
                                                <GradientStop Color="#FFA3CBF7" Offset="0"/>
                                                <GradientStop Color="#FFD9E6F9" Offset="1"/>
                                            </LinearGradientBrush>
                                        </ContentControl.Background>
                                        <StackPanel Orientation="Horizontal">
                                            <StackPanel.Background>
                                                <LinearGradientBrush StartPoint="0.5,0.0" EndPoint="0.5,1.0">
                                                    <GradientStop Color="#C7DEFD" Offset="1"/>
                                                    <GradientStop Color="#F4F9FF" Offset="0.5" />
                                                </LinearGradientBrush>
                                            </StackPanel.Background>
                                            <Path Stroke="#9AC6FF" StrokeThickness="1" Margin="0,0,3,0">
                                                <Path.Data>
                                                    <PathGeometry>
                                                        <PathGeometry.Figures>
                                                            <PathFigureCollection>
                                                                <PathFigure StartPoint="0,0">
                                                                    <PathFigure.Segments>
                                                                        <PathSegmentCollection>
                                                                            <LineSegment Point="0,15" />
                                                                        </PathSegmentCollection>
                                                                    </PathFigure.Segments>
                                                                </PathFigure>
                                                            </PathFigureCollection>
                                                        </PathGeometry.Figures>
                                                    </PathGeometry>
                                                </Path.Data>
                                            </Path>
                                            <Path Data="M0,0 L8,0 4,4Z" Fill="Gray" Stroke="Gray" VerticalAlignment="Center" HorizontalAlignment="Center"></Path>
                                            <Path Stroke="#9AC6FF" StrokeThickness="1" Margin="3,0,0,0">
                                                <Path.Data>
                                                    <PathGeometry>
                                                        <PathGeometry.Figures>
                                                            <PathFigureCollection>
                                                                <PathFigure StartPoint="0,0">
                                                                    <PathFigure.Segments>
                                                                        <PathSegmentCollection>
                                                                            <LineSegment Point="0,15" />
                                                                        </PathSegmentCollection>
                                                                    </PathFigure.Segments>
                                                                </PathFigure>
                                                            </PathFigureCollection>
                                                        </PathGeometry.Figures>
                                                    </PathGeometry>
                                                </Path.Data>
                                            </Path>
                                        </StackPanel>
                                    </ContentControl>

                                    <Path x:Name="SortArrow"  Margin="0,0,7,0" Visibility="Visible"   Data="M0,0 L1,0 0.5,1 z" DockPanel.Dock="Right"
                                         Width="8" Height="6" Fill="#9CC7FF" Stretch="Fill" 
                                         VerticalAlignment="Center" RenderTransformOrigin="0.5,0.4" />
                               


                                    <TextBlock DockPanel.Dock="Left"
									Text="{Binding}" Margin="4,0,4,0"
									SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
									VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
									HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />

                                </DockPanel>
                            </Border>

                        </WpfToolkit:DataGridHeaderBorder>

                        <Thumb x:Name="PART_LeftHeaderGripper"
							   HorizontalAlignment="Left"
							   Style="{StaticResource ColumnHeaderRightGripperStyle}"/>
                        <Thumb x:Name="PART_RightHeaderGripper"
							   HorizontalAlignment="Right"
							   Style="{StaticResource ColumnHeaderLeftGripperStyle}"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <!--Auto Filter-->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True"></Condition>
                                <Condition SourceName="autofilter"   Property="IsMouseOver" Value="False"></Condition>
                                <Condition SourceName="popupDrag"   Property="Tag" Value="False"></Condition>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="autofilter" Property="ContentTemplate" >
                                <Setter.Value>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <StackPanel.Background>
                                                <LinearGradientBrush StartPoint="0.5,0.0" EndPoint="0.5,1.0">
                                                    <GradientStop Color="#FFA3CBF7" Offset="0"/>
                                                    <GradientStop Color="#FFD9E6F9" Offset="1"/>
                                                </LinearGradientBrush>
                                            </StackPanel.Background>
                                            <Path Stroke="#9AC6FF" StrokeThickness="1" Margin="0,0,3,0">
                                                <Path.Data>
                                                    <PathGeometry>
                                                        <PathGeometry.Figures>
                                                            <PathFigureCollection>
                                                                <PathFigure StartPoint="0,0">
                                                                    <PathFigure.Segments>
                                                                        <PathSegmentCollection>
                                                                            <LineSegment Point="0,15" />
                                                                        </PathSegmentCollection>
                                                                    </PathFigure.Segments>
                                                                </PathFigure>
                                                            </PathFigureCollection>
                                                        </PathGeometry.Figures>
                                                    </PathGeometry>
                                                </Path.Data>
                                            </Path>
                                            <Path Data="M0,0 L8,0 4,4Z" Fill="Gray" Stroke="Gray" VerticalAlignment="Center" HorizontalAlignment="Center"></Path>
                                            <Path Stroke="#9AC6FF" StrokeThickness="1" Margin="3,0,0,0">
                                                <Path.Data>
                                                    <PathGeometry>
                                                        <PathGeometry.Figures>
                                                            <PathFigureCollection>
                                                                <PathFigure StartPoint="0,0">
                                                                    <PathFigure.Segments>
                                                                        <PathSegmentCollection>
                                                                            <LineSegment Point="0,15" />
                                                                        </PathSegmentCollection>
                                                                    </PathFigure.Segments>
                                                                </PathFigure>
                                                            </PathFigureCollection>
                                                        </PathGeometry.Figures>
                                                    </PathGeometry>
                                                </Path.Data>
                                            </Path>
                                        </StackPanel>
                                    </DataTemplate>
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="autofilter" Property="Visibility" Value="Visible"/>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True"></Condition>
                                <Condition SourceName="autofilter"   Property="IsMouseOver" Value="True"></Condition>
                                <Condition SourceName="popupDrag"   Property="Tag" Value="False"></Condition>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="autofilter" Property="ContentTemplate" 
									 >
                                <Setter.Value>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <StackPanel.Background>
                                                <LinearGradientBrush StartPoint="0.5,0.0" EndPoint="0.5,1.0">
                                                    <GradientStop Color="#FFA3CBF7" Offset="0"/>
                                                    <GradientStop Color="#FFD9E6F9" Offset="1"/>
                                                </LinearGradientBrush>
                                            </StackPanel.Background>
                                            <Path Stroke="#9AC6FF" StrokeThickness="1" Margin="0,0,3,0">
                                                <Path.Data>
                                                    <PathGeometry>
                                                        <PathGeometry.Figures>
                                                            <PathFigureCollection>
                                                                <PathFigure StartPoint="0,0">
                                                                    <PathFigure.Segments>
                                                                        <PathSegmentCollection>
                                                                            <LineSegment Point="0,15" />
                                                                        </PathSegmentCollection>
                                                                    </PathFigure.Segments>
                                                                </PathFigure>
                                                            </PathFigureCollection>
                                                        </PathGeometry.Figures>
                                                    </PathGeometry>
                                                </Path.Data>
                                            </Path>
                                            <Path Data="M0,0 L8,0 4,4Z" Fill="Black" Stroke="Black" VerticalAlignment="Center" HorizontalAlignment="Center"></Path>
                                            <Path Stroke="#9AC6FF" StrokeThickness="1" Margin="3,0,0,0">
                                                <Path.Data>
                                                    <PathGeometry>
                                                        <PathGeometry.Figures>
                                                            <PathFigureCollection>
                                                                <PathFigure StartPoint="0,0">
                                                                    <PathFigure.Segments>
                                                                        <PathSegmentCollection>
                                                                            <LineSegment Point="0,15" />
                                                                        </PathSegmentCollection>
                                                                    </PathFigure.Segments>
                                                                </PathFigure>
                                                            </PathFigureCollection>
                                                        </PathGeometry.Figures>
                                                    </PathGeometry>
                                                </Path.Data>
                                            </Path>
                                        </StackPanel>
                                    </DataTemplate>
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="autofilter" Property="Visibility" Value="Visible"/>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="False"></Condition>
                                <Condition SourceName="autofilter"   Property="IsMouseOver" Value="False"></Condition>
                                <Condition SourceName="popupDrag"   Property="IsOpen" Value="True"></Condition>
                                <Condition SourceName="popupDrag"   Property="Tag" Value="False"></Condition>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="autofilter" Property="ContentTemplate" 
									 >
                                <Setter.Value>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <StackPanel.Background>
                                                <LinearGradientBrush StartPoint="0.5,0.0" EndPoint="0.5,1.0">
                                                    <GradientStop Color="#C7DEFD" Offset="1"/>
                                                    <GradientStop Color="#F4F9FF" Offset="0.5" />
                                                </LinearGradientBrush>
                                            </StackPanel.Background>
                                            <Path Stroke="#9AC6FF" StrokeThickness="1" Margin="0,0,3,0">
                                                <Path.Data>
                                                    <PathGeometry>
                                                        <PathGeometry.Figures>
                                                            <PathFigureCollection>
                                                                <PathFigure StartPoint="0,0">
                                                                    <PathFigure.Segments>
                                                                        <PathSegmentCollection>
                                                                            <LineSegment Point="0,15" />
                                                                        </PathSegmentCollection>
                                                                    </PathFigure.Segments>
                                                                </PathFigure>
                                                            </PathFigureCollection>
                                                        </PathGeometry.Figures>
                                                    </PathGeometry>
                                                </Path.Data>
                                            </Path>
                                            <Path Data="M0,0 L8,0 4,4Z" Fill="Black" Stroke="Black" VerticalAlignment="Center" HorizontalAlignment="Center"></Path>
                                            <Path Stroke="#9AC6FF" StrokeThickness="1" Margin="3,0,0,0">
                                                <Path.Data>
                                                    <PathGeometry>
                                                        <PathGeometry.Figures>
                                                            <PathFigureCollection>
                                                                <PathFigure StartPoint="0,0">
                                                                    <PathFigure.Segments>
                                                                        <PathSegmentCollection>
                                                                            <LineSegment Point="0,15" />
                                                                        </PathSegmentCollection>
                                                                    </PathFigure.Segments>
                                                                </PathFigure>
                                                            </PathFigureCollection>
                                                        </PathGeometry.Figures>
                                                    </PathGeometry>
                                                </Path.Data>
                                            </Path>
                                        </StackPanel>
                                    </DataTemplate>
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="autofilter" Property="Visibility" Value="Visible"/>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True"></Condition>
                                <Condition SourceName="popupDrag"   Property="IsOpen" Value="True"></Condition>
                                <Condition SourceName="popupDrag"   Property="Tag" Value="False"></Condition>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="autofilter" Property="ContentTemplate" 
									 >
                                <Setter.Value>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal" Background="{StaticResource HeaderHighlightedBackgoundBrush}">
                                          
                                            <Path Stroke="#9AC6FF" StrokeThickness="1" Margin="0,0,3,0">
                                                <Path.Data>
                                                    <PathGeometry>
                                                        <PathGeometry.Figures>
                                                            <PathFigureCollection>
                                                                <PathFigure StartPoint="0,0">
                                                                    <PathFigure.Segments>
                                                                        <PathSegmentCollection>
                                                                            <LineSegment Point="0,15" />
                                                                        </PathSegmentCollection>
                                                                    </PathFigure.Segments>
                                                                </PathFigure>
                                                            </PathFigureCollection>
                                                        </PathGeometry.Figures>
                                                    </PathGeometry>
                                                </Path.Data>
                                            </Path>
                                            <Path Data="M0,0 L8,0 4,4Z" Fill="Black" Stroke="Black" VerticalAlignment="Center" HorizontalAlignment="Center"></Path>
                                            <Path Stroke="#9AC6FF" StrokeThickness="1" Margin="3,0,0,0">
                                                <Path.Data>
                                                    <PathGeometry>
                                                        <PathGeometry.Figures>
                                                            <PathFigureCollection>
                                                                <PathFigure StartPoint="0,0">
                                                                    <PathFigure.Segments>
                                                                        <PathSegmentCollection>
                                                                            <LineSegment Point="0,15" />
                                                                        </PathSegmentCollection>
                                                                    </PathFigure.Segments>
                                                                </PathFigure>
                                                            </PathFigureCollection>
                                                        </PathGeometry.Figures>
                                                    </PathGeometry>
                                                </Path.Data>
                                            </Path>
                                        </StackPanel>
                                    </DataTemplate>
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="autofilter" Property="Visibility" Value="Visible"/>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition SourceName="popupDrag" Property="Tag" Value="True"></Condition>
                                <Condition Property="IsMouseOver" Value="True"></Condition>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="autofilter" Property="ContentTemplate" 
									 >
                                <Setter.Value>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal" Background="{StaticResource HeaderHighlightedBackgoundBrush}">

                                            <Path Stroke="#9AC6FF" StrokeThickness="1" Margin="0,0,3,0">
                                                <Path.Data>
                                                    <PathGeometry>
                                                        <PathGeometry.Figures>
                                                            <PathFigureCollection>
                                                                <PathFigure StartPoint="0,0">
                                                                    <PathFigure.Segments>
                                                                        <PathSegmentCollection>
                                                                            <LineSegment Point="0,15" />
                                                                        </PathSegmentCollection>
                                                                    </PathFigure.Segments>
                                                                </PathFigure>
                                                            </PathFigureCollection>
                                                        </PathGeometry.Figures>
                                                    </PathGeometry>
                                                </Path.Data>
                                            </Path>
                                            <StackPanel Orientation="Horizontal">
                                                <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
                                                    <Path Data="M0,0 L6,0 3,3Z" Fill="Gray" Stroke="Black" HorizontalAlignment="Center"></Path>
                                                    <Path Stroke="Gray" StrokeThickness="2.5" HorizontalAlignment="Center" Margin="0,-2,0,0" >
                                                        <Path.Data>
                                                            <PathGeometry>
                                                                <PathGeometry.Figures>
                                                                    <PathFigureCollection>
                                                                        <PathFigure StartPoint="0,0">
                                                                            <PathFigure.Segments>
                                                                                <PathSegmentCollection>
                                                                                    <LineSegment Point="0,5" />
                                                                                </PathSegmentCollection>
                                                                            </PathFigure.Segments>
                                                                        </PathFigure>
                                                                    </PathFigureCollection>
                                                                </PathGeometry.Figures>
                                                            </PathGeometry>
                                                        </Path.Data>
                                                    </Path>
                                                </StackPanel>
                                                <Path Data="M0,0 L2,0 1,1Z" Fill="Black" Stroke="Black" HorizontalAlignment="Center" VerticalAlignment="Bottom"></Path>
                                            </StackPanel>

                                            <Path Stroke="#9AC6FF" StrokeThickness="1" Margin="3,0,0,0">
                                                <Path.Data>
                                                    <PathGeometry>
                                                        <PathGeometry.Figures>
                                                            <PathFigureCollection>
                                                                <PathFigure StartPoint="0,0">
                                                                    <PathFigure.Segments>
                                                                        <PathSegmentCollection>
                                                                            <LineSegment Point="0,15" />
                                                                        </PathSegmentCollection>
                                                                    </PathFigure.Segments>
                                                                </PathFigure>
                                                            </PathFigureCollection>
                                                        </PathGeometry.Figures>
                                                    </PathGeometry>
                                                </Path.Data>
                                            </Path>
                                        </StackPanel>
                                    </DataTemplate>
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="autofilter" Property="Visibility" Value="Visible"/>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition SourceName="popupDrag" Property="Tag" Value="True"></Condition>
                                <Condition Property="IsMouseOver" Value="False"></Condition>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="autofilter" Property="ContentTemplate" 
									 >
                                <Setter.Value>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal" Background="{StaticResource HeaderBackgroundBrush}">

                                            <Path Stroke="#9AC6FF" StrokeThickness="1" Margin="0,0,3,0">
                                                <Path.Data>
                                                    <PathGeometry>
                                                        <PathGeometry.Figures>
                                                            <PathFigureCollection>
                                                                <PathFigure StartPoint="0,0">
                                                                    <PathFigure.Segments>
                                                                        <PathSegmentCollection>
                                                                            <LineSegment Point="0,15" />
                                                                        </PathSegmentCollection>
                                                                    </PathFigure.Segments>
                                                                </PathFigure>
                                                            </PathFigureCollection>
                                                        </PathGeometry.Figures>
                                                    </PathGeometry>
                                                </Path.Data>
                                            </Path>
                                            <StackPanel Orientation="Horizontal">
                                                <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
                                                    <Path Data="M0,0 L6,0 3,3Z" Fill="Gray" Stroke="Black" HorizontalAlignment="Center"></Path>
                                                    <Path Stroke="Gray" StrokeThickness="2.5" HorizontalAlignment="Center" Margin="0,-2,0,0" >
                                                        <Path.Data>
                                                            <PathGeometry>
                                                                <PathGeometry.Figures>
                                                                    <PathFigureCollection>
                                                                        <PathFigure StartPoint="0,0">
                                                                            <PathFigure.Segments>
                                                                                <PathSegmentCollection>
                                                                                    <LineSegment Point="0,5" />
                                                                                </PathSegmentCollection>
                                                                            </PathFigure.Segments>
                                                                        </PathFigure>
                                                                    </PathFigureCollection>
                                                                </PathGeometry.Figures>
                                                            </PathGeometry>
                                                        </Path.Data>
                                                    </Path>
                                                </StackPanel>
                                                <Path Data="M0,0 L2,0 1,1Z" Fill="Black" Stroke="Black" HorizontalAlignment="Center" VerticalAlignment="Bottom"></Path>
                                            </StackPanel>

                                            <Path Stroke="#9AC6FF" StrokeThickness="1" Margin="3,0,0,0">
                                                <Path.Data>
                                                    <PathGeometry>
                                                        <PathGeometry.Figures>
                                                            <PathFigureCollection>
                                                                <PathFigure StartPoint="0,0">
                                                                    <PathFigure.Segments>
                                                                        <PathSegmentCollection>
                                                                            <LineSegment Point="0,15" />
                                                                        </PathSegmentCollection>
                                                                    </PathFigure.Segments>
                                                                </PathFigure>
                                                            </PathFigureCollection>
                                                        </PathGeometry.Figures>
                                                    </PathGeometry>
                                                </Path.Data>
                                            </Path>
                                        </StackPanel>
                                    </DataTemplate>
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="autofilter" Property="Visibility" Value="Visible"/>
                        </MultiTrigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="headerBorder" Property="Background" 
									Value="{StaticResource HeaderHighlightedBackgoundBrush}" />

                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="False">
                            <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <!--Sort Indicator-->
                        <Trigger Property="SortDirection" Value="Ascending">
                            <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
                            <Setter TargetName="SortArrow" Property="RenderTransform">
                                <Setter.Value>
                                    <RotateTransform Angle="180" />
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="SortDirection" Value="Descending">
                            <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
                        </Trigger>

                        <Trigger Property="SortDirection" Value="{x:Null}">
                            <Setter TargetName="SortArrow" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <Trigger SourceName="btnClear" Property="IsEnabled" Value="True">
                            <Setter TargetName="popupDrag" Property="Tag" Value="True" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- DataGridRowHeader Gripper -->
    <Style x:Key="RowHeaderGripperStyle" TargetType="{x:Type Thumb}">
        <Setter Property="Height" Value="8"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Cursor" Value="SizeNS"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Padding="{TemplateBinding Padding}"
							Background="{TemplateBinding Background}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!-- DataGridRowHeader Style -->
    <Style x:Key="{x:Type WpfToolkit:DataGridRowHeader}"
		   TargetType="{x:Type WpfToolkit:DataGridRowHeader}">
        <Setter Property="Background" Value="{StaticResource HeaderBackgroundBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource HeaderBorderBrush}" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type WpfToolkit:DataGridRowHeader}">
                    <Grid>
                        <WpfToolkit:DataGridHeaderBorder 
							x:Name="headerBorder"
							IsSelected="{TemplateBinding IsRowSelected}"
							IsHovered ="{TemplateBinding IsMouseOver}"
							IsPressed="{TemplateBinding IsPressed}"
							Background="{TemplateBinding Background}"
							BorderBrush="{TemplateBinding BorderBrush}"
							BorderThickness="1,0,1,1"
							Padding ="{TemplateBinding Padding}"
							Orientation="Horizontal"
							SeparatorVisibility="{TemplateBinding SeparatorVisibility}"
							SeparatorBrush="{TemplateBinding SeparatorBrush}">
                            <Border BorderBrush="{StaticResource HeaderInnerBorderBrush}"
									BorderThickness="0,1,0,0">
                                <StackPanel Orientation="Horizontal">
                                    <ContentPresenter
										SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
										VerticalAlignment="Center"/>
                                    <Control
										SnapsToDevicePixels="false"
										Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type WpfToolkit:DataGridRow}}, Path=(Validation.HasError), Converter={StaticResource bool2VisibilityConverter}}"
										Template="{Binding RelativeSource={RelativeSource AncestorType={x:Type WpfToolkit:DataGridRow}}, Path=ValidationErrorTemplate}" />
                                </StackPanel>
                            </Border>
                        </WpfToolkit:DataGridHeaderBorder>

                        <Thumb x:Name="PART_TopHeaderGripper"
							   VerticalAlignment="Top"
							   Style="{StaticResource RowHeaderGripperStyle}"/>
                        <Thumb x:Name="PART_BottomHeaderGripper"
							   VerticalAlignment="Bottom"
							   Style="{StaticResource RowHeaderGripperStyle}"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="headerBorder" Property="Background" 
									Value="{StaticResource HeaderHighlightedBackgoundBrush}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="headerBorder" Property="Background" 
									Value="{StaticResource HeaderPressedBackgroundBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- DataGrid Style -->
    <Style  TargetType="ExtendedGridControl:ExtendedDataGrid">
        <Setter Property="Background" Value="{StaticResource DefaultControlBackgroundBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource DefaultControlForegroundBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource DefaultControlBorderBrush}" />
        <Setter Property="HorizontalGridLinesBrush" Value="{StaticResource GridLineColorBrush}" />
        <Setter Property="VerticalGridLinesBrush" Value="{StaticResource GridLineColorBrush}" />
        <Setter Property="AlternatingRowBackground" Value="{StaticResource AlternateRowBackgroundBrush}" />
        <Setter Property="ColumnHeaderStyle" Value="{StaticResource ColumnHeaderStyle}"/>
        <Setter Property="BorderThickness" Value="1" />
        <!-- This is needed to force DG to have a non-default value.  Otherwise the DGR.DetailsVisibility cannot have a value of VisibleWhenSelected by default. -->
        <Setter Property="RowDetailsVisibilityMode" Value="VisibleWhenSelected" />
        <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type WpfToolkit:DataGrid}">
                    <Border
						Background="{TemplateBinding Background}"
						BorderBrush="{TemplateBinding BorderBrush}"
						BorderThickness="{TemplateBinding BorderThickness}"
						SnapsToDevicePixels="True"
						Padding="{TemplateBinding Padding}">
                        <ScrollViewer Focusable="false" Name="DG_ScrollViewer">
                            <ScrollViewer.Template>
                                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>

                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>

                                        <!--Left Column Header Corner -->
                                        <Button 
											Command="{x:Static WpfToolkit:DataGrid.SelectAllCommand}"
											Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type WpfToolkit:DataGrid}}, Path=CellsPanelHorizontalOffset}"
											Focusable="false"
											Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type WpfToolkit:DataGrid}}, Path=HeadersVisibility, Converter={x:Static WpfToolkit:DataGrid.HeadersVisibilityConverter}, ConverterParameter={x:Static WpfToolkit:DataGridHeadersVisibility.All}}" />
                                        <!--Column Headers-->
                                        <Primitives:DataGridColumnHeadersPresenter 
											Grid.Column="1" 
											Name="PART_ColumnHeadersPresenter"
											Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type WpfToolkit:DataGrid}}, Path=HeadersVisibility, Converter={x:Static WpfToolkit:DataGrid.HeadersVisibilityConverter}, ConverterParameter={x:Static WpfToolkit:DataGridHeadersVisibility.Column}}"/>

                                        <!--DataGrid content-->
                                        <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" Grid.Row="1" Grid.ColumnSpan="2" CanContentScroll="{TemplateBinding CanContentScroll}" />

                                        <ScrollBar
											Grid.Row="0" Grid.RowSpan="2" Grid.Column="2" Name="PART_VerticalScrollBar"
											Orientation="Vertical"
											Maximum="{TemplateBinding ScrollableHeight}"
											ViewportSize="{TemplateBinding ViewportHeight}"
											Value="{Binding Path=VerticalOffset, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
											Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"/>

                                        <Grid Grid.Row="2" Grid.Column="1">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type WpfToolkit:DataGrid}}, Path=NonFrozenColumnsViewportHorizontalOffset}"/>
                                                <ColumnDefinition Width="*"/>
                                            </Grid.ColumnDefinitions>
                                            <ScrollBar 
												Grid.Column="1"
												Name="PART_HorizontalScrollBar"
												Orientation="Horizontal"
												Maximum="{TemplateBinding ScrollableWidth}"
												ViewportSize="{TemplateBinding ViewportWidth}"
												Value="{Binding Path=HorizontalOffset, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
												Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"/>
                                        </Grid>
                                    </Grid>
                                </ControlTemplate>
                            </ScrollViewer.Template>
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsGrouping" Value="true">
                <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
            </Trigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>